//
//  XianyiXiangqingViewController.m
//  A_HandHeldLOL
//
//  Created by Zhao YanBin on 16/1/21.
//  Copyright © 2016年 zhaoyanbin. All rights reserved.
//

#import "XianyiXiangqingViewController.h"
#import "AFNModel.h"
#import "XianyiModel.h"
#import <UIImageView+WebCache.h>
#import "DetailsViewController.h"
@interface XianyiXiangqingViewController ()
//设置头部布局
@property(nonatomic, retain)UIImageView *iconUrl;
@property(nonatomic, retain)UILabel *name;
@property(nonatomic, retain)UILabel *intro;
@property(nonatomic, retain)UIButton *chakanzhandui;

@property(nonatomic, retain)NSMutableArray *dataArr;
@end

@implementation XianyiXiangqingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.navigationItem.title = @"战队成员";
    
    //头部设置
    [self toubu];
    
    [self data];
}

-(void)toubu
{
    self.iconUrl = [[UIImageView alloc] init];
    _iconUrl.frame = CGRectMake(140, 100, 100, 100);
    _iconUrl.backgroundColor = [UIColor redColor];
    [self.view addSubview:_iconUrl];
    [_iconUrl release];
    
    self.name = [[UILabel alloc] initWithFrame:CGRectMake(150, 200, 70, 30)];
    _name.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:_name];
    [_name release];
    
    self.intro = [[UILabel alloc] initWithFrame:CGRectMake(10, 300, self.view.frame.size.width - 20, 200)];
    self.intro.numberOfLines = 0;
    _intro.backgroundColor = [UIColor blueColor];
    [self.view addSubview:_intro];
    [_intro release];
    
    
    self.chakanzhandui = [UIButton buttonWithType:UIButtonTypeSystem];
    _chakanzhandui.frame = CGRectMake(0, self.view.frame.size.height - 99, self.view.frame.size.width, 50);
    _chakanzhandui.backgroundColor = [UIColor redColor];
    [_chakanzhandui setTitle:@"查看战队" forState:UIControlStateNormal];
    [_chakanzhandui addTarget:self action:@selector(chakan:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_chakanzhandui];
    
}

-(void)chakan:(UIButton *)btn
{
    DetailsViewController *detVC = [[DetailsViewController alloc] init];
    detVC.detailsid = [_dataArr[0] team_id];
    [self.navigationController pushViewController:detVC animated:YES];
}

//网络请求
-(void)data
{
    //网址拼接
    NSString *str1 = @"http://qt.qq.com/php_cgi/lol_mobile/club/varcache_star_index.php?id=";
    NSString *str2 = @"&plat=ios&version=801";
    NSString *str = [NSString stringWithFormat:@"%@%@%@",str1,_duiyuanid,str2];
    [AFNModel GETWithURL:str completion:^(id result) {
        NSArray *arr = result[@"members"];
        self.dataArr = [XianyiModel modelHanderWithArray:arr];
        XianyiModel *m = _dataArr[0];
        _name.text = m.full_name;
        _intro.text = m.intro;
        [self.iconUrl sd_setImageWithURL:[NSURL URLWithString:m.iconUrl]];
    }];

    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
